package day_2022_4_to_7.day48;

/**
 * 淘宝网店
 * @author haomin
 * @date 2022/05/31 08:47
 **/

import java.util.Scanner;

public class Day32_1_Income {
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        while(in.hasNext()){
            int year1 = in.nextInt();
            int month1 = in.nextInt();
            int day1 = in.nextInt();
            int year2 = in.nextInt();
            int month2 = in.nextInt();
            int day2 = in.nextInt();

            int income = 0;
            // 开始年后收入（例如：2022-5-31 ~ 2022-12-31）
            income = yearIncome(year1) - thisYearIncome(year1,month1,day1-1);
            // 结束年前收入（例如：2022-1-1 ~ 2022-5-31）
            income += thisYearIncome(year2,month2,day2);

            // 如是同一年 减去当前年多算的收入（一年的）
            if(year1 == year2){
                income -= yearIncome(year1);
            }
            // 期间年收入
            for (int i = year1 + 1; i < year2; i++) {
                income += yearIncome(i);
            }
            System.out.println(income);

        }
    }
    //计算从当前年的1月1号到当前年的month月day号的收益
    private static int thisYearIncome(int year,int month,int day){
        int mIncome = 0;
        if(!isPrimeNumber(month)){
            mIncome = day*2;
        }else {
            mIncome = day;
        }
        while (--month > 0){
            switch(month){
                case 1: mIncome += 31*2;
                    break;
                case 2: mIncome += (28 + (isLeapYear(year) ? 1 : 0));
                    break;
                case 3: mIncome += 31;
                    break;
                case 4: mIncome += 30*2;
                    break;
                case 5: mIncome += 31;
                    break;
                case 6: mIncome += 30*2;
                    break;
                case 7: mIncome += 31;
                    break;
                case 8: mIncome += 31*2;
                    break;
                case 9: mIncome += 30*2;
                    break;
                case 10: mIncome += 31*2;
                    break;
                case 11: mIncome += 30;
                    break;
                case 12: mIncome += 31*2;
                    break;
            }
        }
        return mIncome;
    }

    //判断某月是否是素数
    private static boolean isPrimeNumber(int month){
        if(month == 2 || month == 3 || month == 5 || month == 7 || month == 11){
            return true;
        }else {
            return false;
        }
    }

    //判断某年一共有多少收益
    private static int yearIncome(int year){
        return 2 * 31 + 1 * 28 + 1 * 31 + 2 * 30 + 1 * 31 + 2 * 30 + 1 * 31 + 2 * 31 + 2 * 30 + 2 * 31 + 1 * 30 + 2 * 31
                + (isLeapYear(year) ? 1 : 0);
    }

    //判断是否是闰年
    private static boolean isLeapYear(int year){
        if(((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)){
            return true;
        }else{
            return false;
        }
    }
}